

import joblib
from sklearn.metrics import accuracy_score
from feature_engineering import load_config
from . feature_engineering import feature_engineering_random_forest,load_config


# 预测随机森林模型（在需要时）
def predict_random_forest():
    config = load_config('ssq')
    _, X_test_red, _, y_test_red, _, X_test_blue, _, y_test_blue = feature_engineering_random_forest()
 
    # 加载模型（在需要时）
    loaded_red_model = joblib.load(config['model']['random_forest']['model_red_path'])
    loaded_blue_model = joblib.load(config['model']['random_forest']['model_blue_path'])

    # 使用加载的模型进行预测
    new_red_predictions = loaded_red_model.predict(X_test_red)
    new_blue_predictions = loaded_blue_model.predict(X_test_blue)

    print(f'加载后的红球模型准确率: {accuracy_score(y_test_red, new_red_predictions):.2f}')
    print(f'加载后的蓝球模型准确率: {accuracy_score(y_test_blue, new_blue_predictions):.2f}')